<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑页面</title>
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap-fileinput/fileinput.min.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/animate.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/style.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/common.css">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-md-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="bannerEditForm">
                        <input type="hidden" value="${(entity.id)}" name="id"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">横幅标题：</label>
                            <div class="col-sm-9">
                                <input value="${(entity.title)!}" type="text" id="title" name="title"
                                       class="form-control" placeholder="请输入标题" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">跳转链接：</label>
                            <div class="col-sm-9">
                                <input value="${(entity.linkUrl)!}" type="text" id="linkUrl" name="linkUrl"
                                       class="form-control" placeholder="请输入跳转链接" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">开始时间：</label>
                            <div class="col-sm-9">
                                <div class="col-sm-6 input-group">
                                    <input id="startTime" name="startTime" type="text" autocomplete="off" placeholder="请输入开始时间" value="${entity.startTime?string('yyyy-MM-dd HH:mm:ss')}" class="form-control item-datetime" required>
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">结束时间：</label>
                            <div class="col-sm-9">
                                <div class="col-sm-6 input-group">
                                    <input id="endTime" name="endTime" type="text" autocomplete="off" placeholder="请输入关闭时间" value="${entity.endTime?string('yyyy-MM-dd HH:mm:ss')}" class="form-control item-datetime" required>
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">显示图片：</label>
                            <div class="col-sm-9">
                                <input type="hidden" id="picUrl" name="picUrl" value="${(entity.picUrl)!}">
                                <div class="file-loading">
                                    <input id="uploadImg" name="file" type="file">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">展示位置：</label>
                            <div class="col-sm-9">
                                <label class="radio-inline">
                                    <input name="position" class="minimal" type="radio" ${(entity.position==1)?string('checked','')} value="1" required> 首页
                                </label>
                                <label class="radio-inline">
                                    <input name="position" class="minimal" type="radio" ${(entity.position==2)?string('checked','')} value="2" required> 其他
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动内容：</label>
                            <div class="col-sm-9">
                                <textarea id="content" name="content" class="form-control"
                                          placeholder="请输入活动内容" required>${(entity.content)!}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否启用：</label>
                            <div class="col-sm-9">
                                <label class="radio-inline">
                                    <input name="enabled" class="minimal" type="radio" ${(entity.enabled==1)?string('checked','')} value="1" required> 启用
                                </label>
                                <label class="radio-inline">
                                    <input name="enabled" class="minimal" type="radio" ${(entity.enabled==0)?string('checked','')} value="0" required> 禁用
                                </label>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 通用js引入 -->
<script src="${request.contextPath}/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="${request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/plugins/select2/select2.full.min.js"></script>
<script src="${request.contextPath}/plugins/layer/layer.min.js"></script>
<script src="${request.contextPath}/plugins/laydate/laydate.js"></script>
<script src="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.js"></script>
<script src="${request.contextPath}/plugins/validate/jquery.validate.min.js"></script>
<script src="${request.contextPath}/plugins/validate/messages_zh.min.js"></script>
<script src="${request.contextPath}/plugins/blockUI/jquery.blockUI.js"></script>
<script src="${request.contextPath}/plugins/bootstrap-fileinput/fileinput.min.js"></script>
<script src="${request.contextPath}/hadmin/js/content.js"></script>
<script src="${request.contextPath}/hadmin/js/common.js?v=0.9"></script>
<script>
    // 单图上传
    $("#uploadImg").fileinput({
        uploadUrl: '${request.contextPath}/oss/file/upload',
        maxFileCount: 1,
        autoReplace: true,
        initialPreviewAsData: true,
        initialPreview: ['${(entity.picUrl)!}'],
    }).on('fileuploaded', function (event, data, previewId, index) {
        var rsp = data.response;
        console.log("return fileUrl：" + rsp.fileUrl);
        console.log("reutrn fileName：" + rsp.fileName);
        $('#picUrl').val(rsp.fileUrl);
    }).on('fileremoved', function (event, id, index) {
        $('#picUrl').val('');
    }).on('filecleared', function(event) {
        $('#picUrl').val('');
    })
    // 提交保存
    function submitHandler() {
        if ($("#bannerEditForm").validate().form()) {
            saveInfo('${request.contextPath}/knowledge/banner/doEdit', $('#bannerEditForm').serialize());
        } else {
            $("html,body").animate({scrollTop:0},1000);
            layer.msg("输入数据错误");
        }
    }
</script>
</body>
</html>
